#!/bin/sh
#
# CUAV X25-EVO specific board sensors init
#------------------------------------------------------------------------------
set HAVE_PM2 yes

if mft query -q -k MFT -s MFT_PM2 -v 0
then
	set HAVE_PM2 no
fi

if param compare -s ADC_ADS1115_EN 1
then
	ads1115 start -X
	board_adc start -n
else
	board_adc start
fi

if param compare SENS_EN_INA226 1
then
	# Start Digital power monitors
	ina226 -X -b 1 -t 1 -k start

	if [ $HAVE_PM2 = yes ]
	then
		ina226 -X -b 2 -t 2 -k start
	fi
fi

if param compare SENS_EN_INA228 1
then
	# Start Digital power monitors
	ina228 -X -b 1 -t 1 -k start
	if [ $HAVE_PM2 = yes ]
	then
		ina228 -X -b 2 -t 2 -k start
	fi
fi

if param compare SENS_EN_INA238 1
then
	# Start Digital power monitors
	ina238 -X -b 1 -t 1 -k start
	if [ $HAVE_PM2 = yes ]
	then
		ina238 -X -b 2 -t 2 -k start
	fi
fi

iim42652 -s -b 1 -R 2 -C 32768 start
iim42653 -s -b 2 -R 27 start
iim42653 -s -b 5 -R 12 start

rm3100 -s -b 4 start

bmp581 -s -b 4 start
icp201xx -I -b 4 start

# External compass on GPS1/I2C1 (the 3rd external bus): standard Holybro Pixhawk 4 or CUAV V5 GPS/compass puck (with lights, safety button, and buzzer)
ist8310 -X -b 1 -R 10 start

unset HAVE_PM2
